<template>
  <div>
    <van-nav-bar
      class="nav-bar"
      :title="route.meta.title"
      v-show="route.meta.isShowNav"
      @click-left="onClickLeft"
      :left-arrow="route.meta.isShowBack"
      fixed
      placeholder
      style="height: 50px"
    >
    </van-nav-bar>
    <!-- <p>学号后三位+姓名</p> -->
    <router-view></router-view>
    <tab-bar v-if="isShowTabbar"></tab-bar>
  </div>
</template>
<script setup>
import TabBar from "./components/TabBar.vue";
import { useRoute } from "vue-router";
import { ref, watch } from "vue";
// 1.导入路由对象
import { useRouter } from "vue-router";

const route = useRoute();
const isShowTabbar = ref(true);
// 2.创建路由对象
const router = useRouter();
// 3.
const onClickLeft = () => {
  if (history.length > 1) {
    router.back();
    return;
  } else {
    router.push({ name: "home" });
  }
};

watch(
  () => route.meta,
  (val) => {
    isShowTabbar.value = val.isTab;
  }
);
</script>
<style scoped>
#app {
  color: #2c3e50;
  line-height: 24px;
  --van-nav-bar-background: #ff8000;
  /* --van-nav-bar-background: #ff8000; */
  --van-nav-bar-title-text-color: #fff;
  --van-nav-bar-icon-color: #fff;
}
</style>
